class BidsController < ApplicationController

  active_scaffold :bid do |config|
  
  config.actions.exclude :search
  config.actions.exclude :show
  
  config.columns[:cap_receipt].calculate = "sum"
  config.columns[:cap_spend].calculate = "sum"
  config.columns[:cap_retail_spend].calculate = "sum"
  config.columns[:address].calculate = "count"
  
  list.sorting = {:prop_ref => 'ASC'}
  
  list.columns = [:area,:prop_ref,:address,:business_unit,:prop_dept_contact,:project_type,:business_case,:on_target,:cashflow_qtr,:cap_receipt,:cap_spend,:cap_retail_spend,:completed,:comments]
  
  list.per_page = 1000
  list.label = "Top 20 Bids 2007"
  columns[:year].label = "Y."
  columns[:year].description = "Year"
  
  columns[:territory].label = "T."
  columns[:territory].description = "Territory"
  
  columns[:area].label = "A."
  columns[:area].description = "Area"
  
  columns[:prop_ref].label = "PR."
  columns[:prop_ref].description = "Property Reference"
  
  columns[:address].label = "Town"
  columns[:address].description = "Town"
  
  columns[:business_unit].label = "Div"
  columns[:business_unit].description = "Division: CT Ops/Retail Ops/CT/Terr CT Ops/CT/Options Ops/CT/Terr/UKO"
  
  columns[:prop_dept_contact].label = "Man"
  columns[:prop_dept_contact].description = "Contact: GM AN MD SR&GP GP MJ GA AN&CH DE CH GP&AW GP&AN"
  
  columns[:project_type].label = "P."
  columns[:project_type].description = "Type: A, D, C, D/A or Sub"
  
  columns[:business_case].label = "B. Case"
  columns[:business_case].description = "Business Case: Draft N/A Yes No Awaited Approved"
  
  columns[:on_target].label = "On Target"
  columns[:on_target].description = "On Target: Draft Y N 2008 2009 2010 Undecided"
  
  columns[:cashflow_qtr].label = "Qtr"
  columns[:cashflow_qtr].description = "Cashflow Quarter: Q1 Q2 Q3 Q4 2008 2009 2010"
  
  columns[:completed].label = "C"
  columns[:completed].description = "Completed: Y N"
  
  columns[:cap_receipt].label = "Repeipt"
  columns[:cap_receipt].description = "Capital Receipt"
  
  columns[:cap_spend].label = "Spend"
  columns[:cap_spend].description = "Capital Spend"
  
  columns[:cap_retail_spend].label = "Retail"
  columns[:cap_retail_spend].description = "Retail Cap Spend"
  
  columns[:comments].label = "Comments"
  columns[:comments].description = "Comments"
  
  end

  def conditions_for_collection
   ['territory = ? and year = ?', params[:terr], params[:yr] ]
  end

end
